home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / rexx / start_tex.rexx < prev    next >
OS/2 REXX Batch file  |  1991-07-28  |  3KB  |  133 lines

  1. /*RX
  2.  * AREXX    Name:Start_TeX.rexx    Version:1.41    Date:27-Jul-91
  3.  *
  4.  This AREXX script compiles the files given in argument, using an
  5. optional format argument. All in all, it handles as if you had called
  6. virtex directly (except if you want to pass virtex some options). As
  7. the server is called, any virtex error messages will go to the server
  8. window, not the CLI. A '?' formatname will interactively ask for the
  9. format to use.
  10.  *
  11. AUTHOR:
  12.  *    J\"org H\"ohle, March 91
  13.  *    Revised: 21 April 1991
  14. BUGS:
  15.  virtex doesn't like filenames with blanks (and ARexx parses them
  16. hardly too), so avoid them in file, directory *and* device names.
  17.  *
  18.  does not like names relative to the local root, like ":foo/bar"
  19.  *
  20. FILES:
  21.  ENV:TEXFORMAT: default format used
  22.  REXX:namestruc
  23.  *
  24.  */
  25.  
  26. OPTIONS RESULTS
  27.  
  28. SIGNAL ON BREAK_C
  29. SIGNAL ON BREAK_D
  30.  
  31. portname = 'Start_TeX'
  32. /**
  33. TeXRexx     = "TeX:rexx/"        / * where our scripts stay    * /
  34. namestruc= TeXRexx||'namestruc'
  35. **/
  36. script     = 'TeX-server.rexx'    /* no path required, message only    */
  37.  
  38. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  39. ELSE askformat = 1        /* ask interactively for format name    */
  40.  
  41. PARSE ARG format fullname
  42. IF "?" = format THEN DO
  43.     askformat= 1
  44.     format     = ""
  45.     END
  46. ELSE IF '&' = LEFT(format,1) THEN
  47.     format = SUBSTR(format,2)
  48. ELSE DO
  49.     PARSE ARG fullname    /* no format given */
  50.     format = ""
  51.     END
  52.  
  53. fullname = STRIP(fullname)
  54.  
  55. /**
  56. namestruc fullname
  57. IF 0~= RC THEN DO
  58.     say "Function "namestruc" not found!"
  59.     EXIT 10
  60.     END
  61. ELSE PARSE VALUE RESULT WITH ivol idirs ibase .
  62. **/
  63. PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
  64.  
  65. IF "" == SUBSTR(fullname, 1+ivol+idirs+ibase) THEN
  66.     fullname = fullname||".tex"    /* supply a default extension    */
  67.  
  68. IF 0 = ivol THEN DO
  69.     direc = PRAGMA('d')
  70.     IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
  71.     fullname = direc||fullname
  72.     DROP direc
  73.     END
  74. DROP ivol idirs ibase
  75.  
  76. IF ~EXISTS(fullname) THEN DO
  77.     say 'Sorry, cannot find 'fullname'!'
  78.     EXIT 10
  79.     END
  80.  
  81. IF (SHOW('P', portname)) THEN DO
  82.     envformat = mygetenv("TEXFORMAT")
  83.     IF "" = format THEN DO
  84.         format = envformat
  85.         IF askformat | "" = envformat THEN DO
  86.         IF "" = format THEN format = 'plain'
  87.  
  88.         OPTIONS PROMPT 'Which format to use (default 'format')? '
  89.         PARSE PULL nformat .
  90.         OPTIONS PROMPT
  91.         IF "" ~= nformat THEN format = nformat
  92.  
  93.         END /* askformat */
  94.         END /* !format */
  95.  
  96.     /* If the server is already busy with some compilation, this will
  97.     wait till compilation finishes, thus may take a long time. */
  98.  
  99.     say 'calling TeX server with format 'format' and file 'fullname'.'
  100.     if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  101.     ADDRESS VALUE portname
  102.     'compile' format fullname
  103.     say 'TeX server called for file 'fullname'.'
  104.     END
  105. ELSE DO
  106.     /* The TeX server must be started first */
  107.     say 'The TeX server 'script' is not running !'
  108.     EXIT 5
  109.     END
  110.  
  111. break_c:
  112. break_d:
  113. EXIT
  114.  
  115.  
  116. mygetenv: procedure    /* when will ARexx supply GetEnv/SetEnv ? */
  117.    PARSE ARG name
  118.  
  119.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  120.     gives = readln(TEMPFILE)
  121.     CALL close TEMPFILE
  122.     END
  123.    ELSE gives = ""
  124.  
  125.    RETURN gives
  126.  
  127. mysetenv: procedure
  128.    PARSE ARG name,content
  129.  
  130.    ADDRESS COMMAND "SetEnv" name content
  131.  
  132.    RETURN
  133.